import './utils/polyfill';
import { getUserInfo, login } from "./service/user";
import { getHistory } from "./utils/history";
import update from "./utils/update";
import { useRequest } from "./utils/request";

App({
    messageNumber: 0,
    onLaunch: function () {
        // 更新
        update()
        // 获取历史记录
        this.history = getHistory()
        // 尝试登录
        // 获取用户信息
        login().then(getUserInfo)

        new useRequest('api/usermsgalreadyread', { hold: true })
            .run()
            .then(data => {
                this.messageNumber = data.system_msg_num + data.owner_msg_num + data.order_msg_num
            })

    },
    onPageNotFound() {
        wx.redirectTo({
            url: '/pages/route/404/404'
        })
    }
})
